import type { OrderConfirm, OrderRest } from '@/types/Order';
import type { OrderResp } from'@/types/OrderResp';
import type { OrderListParams }from'@/types/OrderListParams';
import type { orderMember } from '@/types/OrderResp';
import type { confirmOrder } from '@/types/ConfirmOrder';
import request from "@/utils/http"

// 展示订单信息
export const getOrderApi = (data: confirmOrder) => {
  return request<OrderConfirm>({
    url:'oms/front/order/toTrade',
    method:"POST",
    data,
  })
}

// 提交订单
export const createOrderApi = (data: OrderRest) => {
  return request({
    url:'oms/front/order/create',
    method:"POST",
    data,
  })
}

// 查询订单和订单项信息
export const getOrderAndItemInfoApi = (id: number) => {
  return request<OrderResp>({
    url:`oms/front/order/info/${id}`,
    method:"GET",
  })
}

// 用户查询订单
export const getOrderMemberInfoApi = (data:OrderListParams) => {
  return request<orderMember>({
    url:'oms/front/order/member',
    method:"GET",
    data,
  })
}


// 删除订单
export const deleteOrderInfoApi = (orderId: number) => {
  return request({
    url:`oms/front/order/delete/${orderId}`,
    method:"DELETE",
  })
}

// 确认收货
export const confirmGoodsApi = (orderId: number) => {
  return request({
    url:`oms/front/order/update/confirm/${orderId}`,
    method:"PUT",
  })
}

// 取消订单
export const cancelOrderApi = (orderId: number) => {
  return request({
    url:`oms/front/order/cancel/${orderId}`,
    method:"POST",
  })
}